package com.axjy.service.impl;

import com.axjy.mapper.UserMapper;
import com.axjy.pojo.User;
import com.axjy.service.UserService;
import com.axjy.service.vo.Pager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by asus on 2018/1/30.
 */
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;


    @Transactional(readOnly = true)
    public Pager searchPager(Integer offset, Integer limit, String userName, Integer userStatus) {
        Pager pager=new Pager();
        pager.setRows(userMapper.findRows(offset, limit, userName, userStatus));
        pager.setTotal(userMapper.findTotal(userName, userStatus));
        return pager;
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }

    @Override
    public void addUser(User user) {
        userMapper.addUser(user);
    }

    @Override
    public void updateStatus(Integer id, Integer userStatus) {
        userMapper.updateStatus(id, userStatus);
    }

    @Override
    public User Login(String userCode, String userPassword) {
        return userMapper.Login(userCode, userPassword);
    }

    @Override
    public void editUser(User user) {
        userMapper.editUser(user);
    }

    @Override
    public int getRoleId(Integer roleId) {
        return userMapper.getRoleId(roleId);
    }

    @Override
    public void delUser(Integer roleId) {
        userMapper.delUser(roleId);
    }

    @Override
    public User getUser(String userCode) {
        return userMapper.getUser(userCode);
    }

    @Override
    public void updateByRoleId(Integer userId, Integer roleId) {
        userMapper.updateByRoleId(userId, roleId);
    }

    @Override
    public void updatLoginTime(String userCode) {
        userMapper.updatLoginTime(userCode);
    }
}
